package com.syn.synold4s.control;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import com.gaoyi.basemodule.baseControl.BaseView;
import com.syn.synold4s.R;
import com.syn.synold4s.databinding.SettingValueViewBinding;

public class SettingValueView extends BaseView<SettingValueViewBinding> {

    public SettingValueView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void initView(TypedArray ta) {
        String title = ta.getString(R.styleable.SettingValueView_setting_value_title);
        String content = ta.getString(R.styleable.SettingValueView_setting_value_content);
        if (!TextUtils.isEmpty(title)) {
            mBinding.tvSettingTitle.setText(title);
        }
        if (!TextUtils.isEmpty(content)) {
            mBinding.tvSettingValue.setText(content);
        }
    }

    /**
     * 右边内容
     */
    public void setContent(String content) {
        mBinding.tvSettingValue.setText(content);
    }

    /**
     * 右边内容
     */
    public void setContentId(int resId) {
        mBinding.tvSettingValue.setText(resId);
    }

    @Override
    protected SettingValueViewBinding getViewBinding() {
        return SettingValueViewBinding.inflate(LayoutInflater.from(mContext));
    }

    @Override
    protected int[] getAttrs() {
        return R.styleable.SettingValueView;
    }
}
